package com.alumni_circle.mapper.home;

import com.alumni_circle.entity.home.PartTime;
import com.alumni_circle.entity.home.VO.LostFoundListVO;
import com.alumni_circle.entity.home.VO.PartTimeListVO;
import com.alumni_circle.entity.home.VO.PartTimeViewVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

/**
 * @author 龙小虬
 * @since 2020-07-06 22:11
 */
public interface PartTimeMapper extends BaseMapper<PartTime> {

//    @Select("SELECT part_time.title,part_time.content,part_time.unit,part_time.create_time,part_time.money,part_time.settlement,part_time.time,user.`name`,user.`icon`\n" +
//            "FROM user_part,user,part_time\n" +
//            "WHERE user.id = user_part.user_id and user_part.part_id = part_time.id\n" +
//            "ORDER BY create_time DESC")
//    List<PartTimeViewVO> selectListPartTime();

    /**
     * 兼职大厅中的排序后的数据
     * @param count
     * @return
     */
    @Select("SELECT part_time.post,part_time.title,part_time.content,part_time.unit,part_time.create_time,part_time.money,part_time.settlement,part_time.time,user.`name`,user.`icon`\n" +
            "FROM user_part,user,part_time\n" +
            "WHERE user.id = user_part.user_id and part_time.state = '0' and user_part.part_id = part_time.id\n" +
            "ORDER BY #{count} DESC")
    List<PartTimeViewVO> selectListPartTime(@Param("count") String count);
//
//    @Select("SELECT part_time.title,part_time.content,part_time.unit,part_time.create_time,part_time.money,part_time.settlement,part_time.time,user.`name`,user.`icon`\n" +
//            "FROM user_part,user,part_time\n" +
//            "WHERE user.id = user_part.user_id and user_part.part_id = part_time.id\n" +
//            "ORDER BY create_time DESC")
//    List<PartTimeViewVO> selectHotListPartTime();
//

    /**
     * 自己发布的兼职
     * @param id
     * @return
     */
    @Select("SELECT part_time.id,part_time.title,part_time.post,part_time.picture,part_time.content,part_time.unit,part_time.create_time,part_time.money,part_time.settlement,part_time.time,user.`name`,user.`icon`\n" +
            "FROM user_part,user,part_time\n" +
            "WHERE user.id = user_part.user_id and part_time.state = '0' and user_part.part_id = part_time.id and user.id = #{id}\n" +
            "ORDER BY create_time DESC")
    List<PartTimeViewVO> selectMyListPartTime(@Param("id") String id);

    @Select("SELECT part_time.id,part_time.title,part_time.post,part_time.picture,part_time.content,part_time.unit,part_time.create_time,part_time.money,part_time.settlement,part_time.time,user.`name`,user.`icon`\n" +
            "FROM user_part,user,part_time\n" +
            "WHERE (user.id = user_part.user_id and part_time.state = '0' and user_part.part_id = part_time.id and user.id = #{id})  and  (part_time.content like concat('%',#{search},'%') or part_time.title like concat('%',#{search},'%') or " +
            "part_time.unit like concat('%',#{search},'%') or part_time.post like concat('%',#{search},'%') )\n" +
            "ORDER BY create_time DESC")
    List<PartTimeViewVO> searchMyListPartTime(@Param("id") String id, @Param("search") String search);
}
